import axios from 'axios'

const requests=axios.create({
  baseURL:"/api",
  timeout:10000,
  withCredentials:true
})
 //请求拦截器
requests.interceptors.request.use(config=>{
  return config
},err=>{
  console.log(err)
}
)
//响应拦截
requests.interceptors.response.use(config=>{
  return config
},err=>{
  console.log(err)
}
)

export function request(url,params){
     if(params){
      params={
        params:params
      }
     
      return requests.get(url,params)
     }else{
      return requests.get(url)
     }
}